package top.kaoshanji.p2ch23a;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * author kaoshanji
 * ^_^
 * create time 2025/3/3 14:36
 */
public class RealServiceCGLibInterceptor implements MethodInterceptor {

    // o 是被代理的类
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {

        System.out.println("entering " + method.getName());

        System.out.println("superName " + methodProxy.getSuperName());

        Object result = methodProxy.invokeSuper(o, objects);

        System.out.println("leaving " + method.getName());

        return result;
    }
}
